home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 April / macformat-049.iso / mac / Shareware Plus / Developers / dropg++ / EXECUTIVE SUMMARY < prev    next >
Encoding:
Text File  |  1996-10-31  |  1.6 KB  |  58 lines  |  [TEXT/ttxt]

  1. SUMMARY
  2. _______
  3.  
  4. Have you ever wished the barrier to entry to programming on the mac was not so
  5. high? 
  6. Did you ever sit down and hack for hours just to get a simple utility such as a
  7. file 
  8. filter going on the mac ? If so, drag and drop C++ is for you.
  9.  
  10. The basic idea is that files you drag and drop onto your application are
  11. immediately 
  12. available as files which you can use standard C and C++ functions to operate on.
  13.  
  14. For example here is an application which gives the size of any file you drop on
  15. it:
  16.  
  17. #include <stdio.h>
  18. #include <sys/stat.h>
  19.  
  20. main(int argc, char **argv)
  21.         {
  22.         char name[99];
  23.         struct stat statbuf;
  24.         strcpy(name, argv[argc-1]);
  25.         if (stat(name, &statbuf)) perror(name),exit(-2);
  26.         printf("File size = %d bytes\n", statbuf.st_size);
  27.         exit(0);
  28.         }
  29.  
  30. and here is a program that performs a similar function, using C++
  31. iostreams instead of printf()
  32.  
  33. #include <stdlib.h>
  34. #include <iomanip.h>
  35. #include <sys/types.h>
  36. #include <sys/stat.h>
  37.  
  38. main(int argc, char **argv)
  39.         {
  40.         char name[99];
  41.         struct stat statbuf;
  42.         strcpy(name, argv[argc-1]);
  43.         if (stat(name, &statbuf)) perror(name),exit(-2);
  44.         cout << "File size = "; 
  45.         cout << dec  << statbuf.st_size << " bytes(" ;
  46.         cout << hex  << statbuf.st_size << " hex)" ;
  47.         cout << endl;
  48.         }
  49.  
  50. The clever bit is that the C/C++ compiler itself is also a drag-and-drop file
  51. filter,
  52. so to generate your new application, you just drop the source code on the 'gcc'
  53. application !
  54.  
  55. Be sure to read the file INSTALLATION and the file COPYING (especially the section
  56. NO WARRANTY) before using this program.
  57.  
  58.